<template>
	<view class="container">
		<view class="banner">
			<image v-if="resource['home_banner']" :src="resource['home_banner'].fileUrl" mode="widthFix"></image>
		</view>
		<view class="content-wrap">
			<view class="block">
				<view class="title-bar">
					<image class="title" src="../../static/img/title/title_fczc.png" mode="widthFix"></image>
				</view>
				<view class="content">
					<view class="menu-box red-box" @click="view('fzzc')">
						<view class="name">扶助政策</view>
						<view class="text">奖特扶扶助政策介绍</view>
						<image class="icon" style="width: 90upx; height: 90upx; padding-right: 10upx; padding-bottom: 10upx;" src="../../static/img/home/icon_zc.png" mode="widthFix"></image>
					</view>
					<view class="menu-box yellow-box" @click="view('gahd')" style="visibility: hidden;">
						<view class="name">关爱活动</view>
						<view class="text">奖特扶关爱活动介绍</view>
						<image class="icon" style="width: 140upx; height: 140upx;" src="../../static/img/home/icon_ax.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<view class="block">
				<view class="title-bar">
					<image class="title" src="../../static/img/title/title_ndsh.png" mode="widthFix"></image>
				</view>
				<view class="content">
					<view class="menu-box yellow-box" @click="view('nsrz')">
						<view class="name">年审认证</view>
						<view class="text">扶助资格年审认证</view>
						<image class="icon" style="width: 90upx; height: 90upx;" src="../../static/img/home/icon_rz.png" mode="widthFix"></image>
					</view>
					<view class="menu-box blue-box" @click="view('rzcx')">
						<view class="name">认证查询</view>
						<view class="text">扶助资格年审认证查询</view>
						<image class="icon" style="width: 90upx; height: 90upx; padding-bottom: 5upx; padding-right: 10upx;" src="../../static/img/home/icon_cx_blue.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<view class="block">
				<view class="title-bar">
					<image class="title" src="../../static/img/title/title_btcx.png" mode="widthFix"></image>
				</view>
				<view class="content">
					<view class="menu-box red-box" @click="view('btcx')">
						<view class="name">补贴查询</view>
						<view class="text">扶助资金发放查询</view>
						<image class="icon" style="width: 90upx; height: 90upx; padding-bottom: 5upx; padding-right: 10upx;" src="../../static/img/home/icon_cx_red.png" mode="widthFix"></image>
					</view>
					<view class="menu-box yellow-box" style="visibility: hidden;">
						<view class="name">扶助政策</view>
						<view class="text">奖特扶政策介绍</view>
						<image class="icon" style="width: 90upx; height: 90upx;" src="../../static/img/home/icon_cx_red.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Store from '@/store/index.js';
	import { ApiResource } from '@/api/application/index.js';
	
	export default {
		data() {
			return {
				user:{
					type: null
				},
				resource: {}
			}
		},
		created() {
			this.getResources();
			if(this.checkLogin()){
				
			}
		},
		onShow() {
			if(this.checkLogin()){
				
			}
		},
		onLoad(option) {
			this.$store.setManageDeptId(option.manageDeptId?option.manageDeptId:'-1');
		},
		methods: {
			//获取网络资源
			getResources(){
				ApiResource.getByCode('home_banner').then(res=>{
					this.resource = {
						'home_banner': res.data
					};
				})
			},
			
			//登录状态检查
			checkLogin(){
				this.user = Store.getUser();
				if(this.user && this.user.id){
					return true;
				}else{
					uni.showToast({
						mask: true,
						title: '请先登录',
						icon: 'none'
					})
					uni.navigateTo({
						url: '/pages/login'
					})
					return false;
				}
			},
			
			view(menu){
				if(menu== 'fzzc'){
					uni.navigateTo({
						url: '/pages/policy/index'
					})
				}else if(menu== 'gahd'){
					uni.navigateTo({
						url: '/pages/activity/index'
					})
				}else if(menu == 'nsrz'){
					uni.navigateTo({
						url: '/pages/identify/schedule?operation=identify'
					})
				}else if(menu == 'rzcx'){
					uni.navigateTo({
						url: '/pages/identify/schedule?operation=query'
					})
				}else if(menu == 'btcx'){
					uni.navigateTo({
						url: this.user.type =='people'?'/pages/subsidy/search/index':'/pages/subsidy/search/person-list'
					})
				}
			}

		}
	}
</script>

<style>
	.container {
		width: 750upx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 0;
		margin: 0;
	}
	.banner{
		width: 100%;
	}
	.banner image{
		width: 750upx;
	}
	.content-wrap{
		padding-bottom: 40upx;
	}
	.title-bar{
		width: 750upx;
		padding: 20upx 30upx;
		box-sizing: border-box;
	}
	.title-bar .title{
		width: 180upx;
	}
	.content{
		padding: 0 30upx;
		display: flex;
		justify-content: space-around;
	}
	.block{
		margin-top: 20upx;
	}
	.menu-box{
		width: 240upx;
		height: 160upx;
		border-radius: 50upx;
		position: relative;
		color: white;
		padding: 40upx;
	}
	.red-box{
		background: linear-gradient(135deg, #FF7272, #FFB197 );
	}
	.yellow-box{
		background: linear-gradient(135deg, #FFA933, #FFE169 );
	}
	.blue-box{
		background: linear-gradient(135deg, #6B9EFF, #90CCFD );
	}
	.menu-box .name{
		font-size: 16px;
		font-weight: bold;
		margin-bottom: 10upx;
	}
	.menu-box .text{
		
	}
	.menu-box .icon{
		width: 120upx;
		position: absolute;
		right: 10upx;
		bottom: 10upx;
	}
</style>
